package com.thon.entity.relation;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.thon.commons.persistence.IdEntity;
import com.thon.entity.system.User;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
 * Created by somedargon on 2017/3/7.
 * 映射表
 */
@Entity
@Table(name="user_inter_relation")
@DynamicInsert
@DynamicUpdate
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserRelation  extends IdEntity{
    private User user;
    private InterRelation inReId;
    private PersonalRelation personalRelation;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @NotFound(action = NotFoundAction.IGNORE)
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "inter_id")
    @NotFound(action = NotFoundAction.IGNORE)
    public InterRelation getInReId() {
        return inReId;
    }

    public void setInReId(InterRelation inReId) {
        this.inReId = inReId;
    }

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "personal_id")
    @NotFound(action = NotFoundAction.IGNORE)
    public PersonalRelation getPersonalRelation() {
        return personalRelation;
    }

    public void setPersonalRelation(PersonalRelation perRelation) {
        this.personalRelation = perRelation;
    }
}
